package com.wenbing.miio.jsonrpc;

public class JsonRpcMessage {

    private String jsonrpc = "2.0";

    private Integer id = -1;

    private String method;

    private Object params;

    private Object result;

    private JsonRpcError error;

    public JsonRpcMessage() {

    }

    public JsonRpcMessage(Integer id, String method, Object params) {
        this.id = id;
        this.method = method;
        this.params = params;
    }

    public static boolean isNotify(JsonRpcMessage message) {
        return message == null || message.getId() == null;
    }

    public String getJsonrpc() {
        return jsonrpc;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;

    }

    public Object getParams() {
        return params;
    }

    public void setParams(Object params) {
        this.params = params;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public void setResult(Object result) {
        this.result = result;
    }

    public Object getResult() {
        return result;
    }

    public void setError(JsonRpcError error) {
        this.error = error;
    }

    public JsonRpcError getError() {
        return error;
    }

    @Override
    public String toString() {
        return "JsonRpcMessage{" +
                "jsonrpc='" + jsonrpc + '\'' +
                ", id=" + id +
                ", method='" + method + '\'' +
                ", params=" + params +
                ", result=" + result +
                ", error=" + error +
                '}';
    }
}
